<?php
if (!isset($_COOKIE["user_dailv"])) {
    header("Location: login.php");
}
$user = $_COOKIE["user_dailv"];
$email = $_COOKIE["email_dailv"];
?>

<html>
    <body style="width: 800px; margin: 20px auto auto auto">
        <form action="" method="post">
            Email:
            <input name="Name" type="text" value="<?= $email ?>" disabled/>
            <p style="text-align: left; float: right;">
                <a href="logout.php">Logout</a>
            </p>
            <br />
            <br />
            <textarea name="Comment" cols="60" rows="5"></textarea><br />
            <br />
            <input type="submit" name="Send" value="Send" />
            <hr />
        </form>
        <?php
        require 'mysql.php';
        if (isset($_POST['Send'])) {
            $Com = $_POST['Comment'];
            $sql1 = "insert into LeVanDai_tblcomment values('','$user','$Com')";
            mysqli_query($link, $sql1);
        }
        $sql_select = "SELECT * FROM LeVanDai_tblcomment,LeVanDai_tbluser WHERE LeVanDai_tblcomment.`User` = LeVanDai_tbluser.`User` ORDER BY ID DESC;";
        $result = mysqli_query($link, $sql_select);
        while ($row = mysqli_fetch_array($result)) {
            echo "<p>";
            echo "<span style='color: #FF0000'>" . $row["Email"] . "</span><br />";
            echo $row["Comment"] . "<br />";
            echo "----------------------------------------------";
        }
        ?>     

    </body>
</html>

